single number c#

89

single number c# -

public int SingleNumber(int[] nums)
        {
         int sNumber = nums[0]; 
            if (nums.Length > 1)
            {
                for (int i = 0; i <= nums.Length - 2; i++)
                {
                    sNumber = sNumber ^ nums[i + 1];
                }
            }           
            return sNumber;
        }

Comments

Submit
0 Comments